const sqlite3 = require('../server/node_modules/sqlite3').verbose();
const path = require('path');

// 创建数据库连接
const dbPath = path.join(__dirname, '../resources/db/db.database');
console.log('Database path:', dbPath);

const db = new sqlite3.Database(dbPath);

// 查询user_course_progress表中的数据，按更新时间排序
db.serialize(() => {
  console.log('\n=== Recent User Course Progress Data (Detailed) ===');
  db.each(`
    SELECT * FROM user_course_progress 
    ORDER BY updated_at DESC
    LIMIT 10
  `, (err, row) => {
    if (err) {
      console.error('Error:', err);
    } else {
      console.log(row);
    }
  }, () => {
    // 查看courses表结构
    console.log('\n=== Courses Table Data ===');
    db.each(`
      SELECT * FROM courses
    `, (err, row) => {
      if (err) {
        console.error('Error:', err);
      } else {
        console.log(row);
      }
    }, () => {
      // 查看lessons表结构
      console.log('\n=== Lessons Table Data ===');
      db.each(`
        SELECT * FROM lessons
      `, (err, row) => {
        if (err) {
          console.error('Error:', err);
        } else {
          console.log(row);
        }
      }, () => {
        db.close();
      });
    });
  });
});